package ${base_pack}.controller;

import cn.jiayen.mvc.page.PagerVO;
import ${base_pack}.service.${name}Service;
import ${base_pack}.views.dto.${name}DTO;
import ${base_pack}.views.vo.${name}VO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Created by jiayen on 2018/5/5.
 */
@Api(tags = "${name}", description = "",value = "${name}")
@RestController
public class ${name}Controller {

    @Autowired
    private ${name}Service ${m_name}Service;
    @ApiOperation(value = "${name}-添加",notes = "添加")
    @RequestMapping(value = "/${m_name}",method = RequestMethod.POST)
    public ${name}VO add${name}(@Valid @RequestBody ${name}DTO ${m_name}DTO){
        ${name}VO result  =   ${m_name}Service.add(${m_name}DTO);
        return  result;
    }

    @ApiOperation(value = "${name}-删除(多个已逗号隔开)",notes = "删除(多个已逗号隔开)")
    @RequestMapping(value = "/${m_name}/{ids}",method = RequestMethod.DELETE)
    public void delete${name}ById(@PathVariable String ids){
        ${m_name}Service.deleteById(ids);
    }

    @ApiOperation(value = "${name}-修改",notes = "修改")
    @RequestMapping(value = "/${m_name}",method = RequestMethod.PUT)
    public ${name}VO update${name}(@Valid @RequestBody ${name}DTO ${m_name}){
        ${name}VO result  =   ${m_name}Service.update(${m_name});
        return  result;
    }

    @ApiOperation(value = "${name}-获取单个",notes = "获取单个")
    @RequestMapping(value = "/${m_name}/{id}",method = RequestMethod.GET)
    public ${name}VO get${name}ById(@PathVariable Integer id){
        ${name}VO ${m_name} = ${m_name}Service.getById(id);
        return  ${m_name};
    }
    @ApiOperation(value = "${name}-获取列表",notes = "获取列表")
    @RequestMapping(value = "/${m_name}s",method = RequestMethod.GET)
    public PagerVO<${name}VO>  get${name}List(@ApiParam(value = "页码从1开始")@RequestParam(required = false,defaultValue = "1") Integer page
            ,@ApiParam(value = "每页数量")@RequestParam(required = false,defaultValue = "10") Integer  pageSize){
        PagerVO<${name}VO>  pagerVO = ${m_name}Service.get${name}List(page,pageSize);
        return  pagerVO;
    }


}
